home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c-part1 / 8569 < prev    next >
Encoding:
Text File  |  1996-08-05  |  1.5 KB  |  55 lines

  1. Path: s02.pavilion.co.uk!usenet
  2. From: AJRobb@pavilion.co.uk (Andy J Robb)
  3. Newsgroups: comp.lang.c
  4. Subject: Re: strange behaviour of doubles
  5. Date: Tue, 05 Mar 1996 02:55:28 GMT
  6. Organization: Pavilion Internet plc
  7. Message-ID: <4hgadl$275@s02.pavilion.co.uk>
  8. References: <1996Mar4.014052.6236@dcs.warwick.ac.uk>
  9. NNTP-Posting-Host: poolc35.pavilion.co.uk
  10. X-Newsreader: Forte Free Agent 1.0.82
  11.  
  12. D.C.Molero@dcs.warwick.ac.uk (Daniel Castillo Molero) wrote:
  13.  
  14.  
  15. >Dear readers,
  16. >Can anybody explain to me why the behaviour of the following little
  17. >program is not the expected one ??
  18. >It is supposed to read from std input pairs of doubles and print them,
  19. >until 0.0 is input.
  20. >The strange thing is that it doesn't print the input number, e.g. when
  21. >I input 1.0 1.0   it prints   0.0078125  0.0078125
  22. >I will appreciate very much any help.
  23.  
  24. You need to use "%lg" to scan into a double.
  25.  
  26. >#include <stdio.h>
  27. >#include <stdlib.h>
  28.  
  29. >main() {
  30. >double x, y;
  31. >scanf("%g", &x);
  32. >while (x != 0.0) {
  33. >  scanf("%g", &y);
  34. >  printf("%g %g\n", x, y);
  35. >  scanf("%g", &x);
  36. >}
  37. >return(0);
  38. >}
  39. >-- 
  40. >* Daniel Castillo.  danmol@dcs.warwick.ac.uk *
  41.  
  42.  
  43.  
  44. -----BEGIN PGP PUBLIC KEY BLOCK-----
  45. Version: 2.6.2i
  46.  
  47. mQCNAy/MpRwAAAEEAOt6uBYqT8yv9EmqNhK8m6v+bYi8QjnGW3Bo6iU1gsMj5pa6
  48. MHgq99c8deADbE3cbJ6uZS9v5pZE3WCf6HCQjlB5iULA5RZzMdAumd/WUzuL9UT3
  49. B44D9EqqFIL79FlYb56v4oKFqFp1/J2bIpYUwnUvabGzGjdLrpPl4P16x9sNAAUR
  50. tCNBbmR5IEogUm9iYiA8QUpSb2JiQHBhdmlsaW9uLmNvLnVrPrQhQW5keSBSb2Ji
  51. IDxBSlJvYmJAcGF2aWxpb24uY28udWs+
  52. =/wVD
  53. -----END PGP PUBLIC KEY BLOCK-----
  54.  
  55.